﻿using System;
using System.Security.Principal;
using ENail.Domain.Core;
using Equation.Enterprise.Framework.Web.Model;

namespace ENail.Portal.Web.Models
{
    public class UserViewModel : IViewModelMapper<User, Int16>, IPrincipal
    {
        public string Username { get; set; }
        public string Password { get; set; }
        public NailSalonViewModel NailSalon { get; set; }

        public void MapFromDomainModel(User model)
        {
            this.Username = model.Username;
            this.Password = model.Password;
            NailSalon = new NailSalonViewModel();
            NailSalon.MapFromDomainModel(model.NailSalon);
        }

        public void MapToDomainModel(User domainModel)
        {
            domainModel.Username = this.Username;
            domainModel.Password = this.Password;
        }

        #region IPrincipal Implementation

        //There is no role for now so always returns true
        public virtual bool IsInRole(string role)
        {
            return true;
        }

        public virtual IIdentity Identity { get; set; }

        #endregion
    }
}